using UnityEngine;
using System.Collections;

public class Tile : MonoBehaviour {

    public Const.TYPE_TILE type;
    public Texture bushTexture;
    public Texture noneTexture;
    public bool editor;

	// Use this for initialization
	void Awake () {
        type = Const.TYPE_TILE.NONE;
        this.renderer.material.SetTexture("_MainTex", noneTexture);
	}
	

    void OnMouseDown()
    {
        if(!editor)
            return;

        if (type == Const.TYPE_TILE.BUSH)
        {
            type = Const.TYPE_TILE.NONE;
            this.renderer.material.SetTexture("_MainTex", noneTexture);
        }
        else
        {
            type = Const.TYPE_TILE.BUSH;
            this.renderer.material.SetTexture("_MainTex", bushTexture);
        }
    }

    public void SetType(Const.TYPE_TILE t)
    {
        type = t;

        if (type == Const.TYPE_TILE.BUSH)
        {
            this.renderer.material.SetTexture("_MainTex", bushTexture);
        }
        else
        {
            this.renderer.material.SetTexture("_MainTex", noneTexture);
        }
    }
}
